var a = require("../../api.js"), o = getApp(), t = require("../../utils/function.js");

Page({
    data: {
        img: t.userImg,
        coupon: wx.getStorageSync("coupon"),
        list: []
    },
    onLoad: function(a) {
        a.uid && o.shareCouponsMessage(a.uid);
    },
    onReady: function() {},
    onShow: function() {
        var t = this;
        wx.showLoading({}), o.request({
            url: a.coupon_list.couponlist,
            method: "post",
            data: {},
            success: function(a) {
                wx.hideLoading(), t.setData({
                    list: a.data
                });
            }
        });
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        var t = this;
        wx.showNavigationBarLoading(), o.request({
            url: a.coupon_list.coupon_list,
            method: "post",
            data: {},
            success: function(a) {
                console.log("优惠卷", a.data.data), t.setData({
                    list: a.data.data
                }), wx.hideNavigationBarLoading();
            }
        });
    },
    onReachBottom: function() {
        var t = this;
        wx.showNavigationBarLoading();
        var s = 1;
        s += 1, o.request({
            url: a.coupon_list.coupon_list,
            method: "post",
            data: {
                page: s
            },
            success: function(a) {
                console.log("优惠卷", a.data.data), t.setData({
                    list: a.data.data
                }), wx.hideNavigationBarLoading();
            }
        });
    },
    exchange:function(e){
        var p =  e.currentTarget.dataset.url
        wx.navigateTo({
          url: p,
        })
       },
    usecpn:function(e){
     var p =   e.currentTarget.dataset.url
     wx.switchTab({
       url: p,
     })

    },
    goshare:function(e){
        var p = e.currentTarget.dataset.url
        wx.navigateTo({
          url: p,
        })
    },
    onShareAppMessage: function() {
        var a = o.shareAppMessage().title, t = o.shareAppMessage().imageUrl, s = o.shareAppMessage().desc, e = o.shareAppMessage().path;
        return console.log(o.shareAppMessage()), {
            title: a,
            imageUrl: t,
            desc: s,
            path: e
        };
    }
});